﻿using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;

namespace ZXW.DotNet.Common.DbUtilities
{
    public static class ConnectionManager
    {
        private const string ConnectionStringBuilderItem =
            @"marvellousWorks.practicalPattern.shwoCase/connectionBuilders";

        private static IDictionary<string, ConnectionStringSettings> _registry;

        static ConnectionManager()
        {
            var collection = (NameValueCollection) (
                ConfigurationManager.GetSection(ConnectionStringBuilderItem));
            var builder = new ConnectionStringBuilder(collection);
            _registry = builder.BulidUp();
        }

        /// <summary>
        /// 获取处理后每个逻辑连接的配置信息
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static ConnectionStringSettings SetSetting(string name)
        {
            return _registry[name];
        }
    }
}